css: Stop parsing GdkColor values
authorTimm Bäder <mail@baedert.org>
Sat, 22 Oct 2016 14:49:42 +0000 (16:49 +0200)
committerTimm Bäder <mail@baedert.org>
Sat, 22 Oct 2016 14:59:47 +0000 (16:59 +0200)
gtk/gtkcssstylefuncs.c
gtk/gtkstylecontext.c

index 24531ea3077d24b3a7091708c69941800e884053..301b05233d370ead167c315c607bec8a65d63c79 100644 (file)
@@ -170,60 +170,6 @@ rgba_value_print (const GValue *value,
     }
 }
 
-static gboolean
-color_value_parse (GtkCssParser *parser,
-                   GValue       *value)
-{
-  GtkSymbolicColor *symbolic;
-  GdkRGBA rgba;
-
-  G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
-
-  symbolic = _gtk_css_symbolic_value_new (parser);
-  if (symbolic == NULL)
-    return FALSE;
-
-  if (gtk_symbolic_color_resolve (symbolic, &rgba))
-    {
-      GdkColor color;
-
-      color.red = rgba.red * 65535. + 0.5;
-      color.green = rgba.green * 65535. + 0.5;
-      color.blue = rgba.blue * 65535. + 0.5;
-
-      g_value_set_boxed (value, &color);
-      gtk_symbolic_color_unref (symbolic);
-    }
-  else
-    {
-      g_value_unset (value);
-      g_value_init (value, GTK_TYPE_SYMBOLIC_COLOR);
-      g_value_take_boxed (value, symbolic);
-    }
-
-  G_GNUC_END_IGNORE_DEPRECATIONS;
-
-  return TRUE;
-}
-
-static void
-color_value_print (const GValue *value,
-                   GString      *string)
-{
-  const GdkColor *color = g_value_get_boxed (value);
-
-  if (color == NULL)
-    g_string_append (string, "none");
-  else
-    {
-G_GNUC_BEGIN_IGNORE_DEPRECATIONS
-      char *s = gdk_color_to_string (color);
-G_GNUC_END_IGNORE_DEPRECATIONS
-      g_string_append (string, s);
-      g_free (s);
-    }
-}
-
 static gboolean
 symbolic_color_value_parse (GtkCssParser *parser,
                             GValue       *value)
@@ -802,10 +748,6 @@ gtk_css_style_funcs_init (void)
 
   G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
 
-  register_conversion_function (GDK_TYPE_COLOR,
-                                color_value_parse,
-                                color_value_print);
-
   register_conversion_function (GTK_TYPE_SYMBOLIC_COLOR,
                                 symbolic_color_value_parse,
                                 symbolic_color_value_print);
index 07ed5a701c1a04deb81a107bbbde80b86f3f49e6..326d7ab3eefff2fcd7f0f1067cce96c5dc39731a 100644 (file)
@@ -1410,7 +1410,7 @@ _gtk_style_context_peek_style_property (GtkStyleContext *context,
         {
           G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
 
-          /* Resolve symbolic colors to GdkColor/GdkRGBA */
+          /* Resolve symbolic colors to GdkRGBA */
           if (G_VALUE_TYPE (&pcache->value) == GTK_TYPE_SYMBOLIC_COLOR)
             {
               GtkSymbolicColor *color;
@@ -1420,26 +1420,11 @@ _gtk_style_context_peek_style_property (GtkStyleContext *context,
 
               g_value_unset (&pcache->value);
 
-              if (G_PARAM_SPEC_VALUE_TYPE (pspec) == GDK_TYPE_RGBA)
-                g_value_init (&pcache->value, GDK_TYPE_RGBA);
-              else
-                g_value_init (&pcache->value, GDK_TYPE_COLOR);
+              g_assert (G_PARAM_SPEC_VALUE_TYPE (pspec) == GDK_TYPE_RGBA);
+              g_value_init (&pcache->value, GDK_TYPE_RGBA);
 
               if (_gtk_style_context_resolve_color (context, _gtk_symbolic_color_get_css_value (color), &rgba))
-                {
-                  if (G_PARAM_SPEC_VALUE_TYPE (pspec) == GDK_TYPE_RGBA)
-                    g_value_set_boxed (&pcache->value, &rgba);
-                  else
-                    {
-                      GdkColor rgb;
-
-                      rgb.red = rgba.red * 65535. + 0.5;
-                      rgb.green = rgba.green * 65535. + 0.5;
-                      rgb.blue = rgba.blue * 65535. + 0.5;
-
-                      g_value_set_boxed (&pcache->value, &rgb);
-                    }
-                }
+                g_value_set_boxed (&pcache->value, &rgba);
               else
                 g_param_value_set_default (pspec, &pcache->value);